package com.lxmes.procontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.procontrol.domain.NcProProcessControl;
import com.lxmes.procontrol.service.INcProProcessControlService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 生产过程控制总Controller
 * 
 * @author ruoyi
 * @date 2022-11-26
 */
@RestController
@RequestMapping("/procontrol/control")
public class NcProProcessControlController extends BaseController
{
    @Autowired
    private INcProProcessControlService ncProProcessControlService;

    /**
     * 查询生产过程控制总列表
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcProProcessControl ncProProcessControl)
    {
        startPage();
        List<NcProProcessControl> list = ncProProcessControlService.selectNcProProcessControlList(ncProProcessControl);
        return getDataTable(list);
    }

    /**
     * 导出生产过程控制总列表
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:export')")
    @Log(title = "生产过程控制总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcProProcessControl ncProProcessControl)
    {
        List<NcProProcessControl> list = ncProProcessControlService.selectNcProProcessControlList(ncProProcessControl);
        ExcelUtil<NcProProcessControl> util = new ExcelUtil<NcProProcessControl>(NcProProcessControl.class);
        util.exportExcel(response, list, "生产过程控制总数据");
    }

    /**
     * 获取生产过程控制总详细信息
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncProProcessControlService.selectNcProProcessControlById(id));
    }
    @GetMapping(value = "/getOrderInfoPg/{id}")
    public AjaxResult getOrderInfoPg(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncProProcessControlService.getOrderInfoPg(id));
    }


    /**
     * 新增生产过程控制总
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:add')")
    @Log(title = "生产过程控制总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcProProcessControl ncProProcessControl)
    {
        return toAjax(ncProProcessControlService.insertNcProProcessControl(ncProProcessControl));
    }
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfo:pg')")
    @Log(title = "工单明细派工", businessType = BusinessType.INSERT)
    @PostMapping("/addOrderInfoPg")
    public AjaxResult addOrderInfoPg(@RequestBody NcProProcessControl ncProProcessControl)
    {
        return toAjax(ncProProcessControlService.addOrderInfoPg(ncProProcessControl));
    }


    /**
     * 修改生产过程控制总
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:edit')")
    @Log(title = "生产过程控制总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcProProcessControl ncProProcessControl)
    {
        return toAjax(ncProProcessControlService.updateNcProProcessControl(ncProProcessControl));
    }
    @GetMapping(value = "/addRukuToOrderInfo/{id}")
    public AjaxResult addJdAllOrderInfo(@PathVariable Long id)
    {
        return toAjax(ncProProcessControlService.addRukuToOrderInfo(id));
    }
    /**
     * 审核生产过程控制
     */
    @PreAuthorize("@ss.hasPermi('procontrol:control:sh')")
    @Log(title = "审核生产过程控制", businessType = BusinessType.UPDATE)
    @GetMapping("/shControl/{ids}")
    public AjaxResult shControl(@PathVariable Long[] ids)
    {
        return toAjax(ncProProcessControlService.shControl(ids));
    }

    @PreAuthorize("@ss.hasPermi('procontrol:control:remove')")
    @Log(title = "生产过程控制总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncProProcessControlService.deleteNcProProcessControlByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('procontrol:control:query')")
	@GetMapping("/handRead")
    public AjaxResult handRead()
    {
        return toAjax(ncProProcessControlService.handRead());
    }


}
